<template>
  <div>
    <p>age: {{ age }}</p>
    <p>address: {{ info.address }}</p>
    <button @click="changeAge">修改 age</button>
    <button @click="changeAddress">修改 address</button>
  </div>
</template>

<script>
export default {
  name: 'Child',
  props: {
    age: {
      type: Number,
    },
    info: {
      type: Object,
    },
  },
  methods: {
    changeAge() {
      // this.age = 199
      this.$emit('changeAge', 188)
    },
    changeAddress() {
      // 引用不能改
      // this.info = { address: '武汉' }
      this.info.address = '武汉'
    },
  },
}
</script>

<style lang="less" scoped></style>
